home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.util;
-
- import java.util.Vector;
-
- public class History {
- Vector history = new Vector();
- int pos = -1;
-
- public void add(Object var1) {
- if (var1 != null && !var1.equals(this.peekThis())) {
- ++this.pos;
- if (this.peekNext() == null || !this.peekNext().equals(var1)) {
- this.history.setSize(this.pos);
- this.history.insertElementAt(var1, this.pos);
- }
-
- }
- }
-
- public Object getPrev() {
- return this.pos < 1 ? null : this.history.elementAt(--this.pos);
- }
-
- public Object getNext() {
- return this.pos >= this.history.size() - 1 ? null : this.history.elementAt(++this.pos);
- }
-
- public Object peekThis() {
- return this.pos < 0 ? null : this.history.elementAt(this.pos);
- }
-
- public Object peekPrev() {
- return this.pos < 1 ? null : this.history.elementAt(this.pos - 1);
- }
-
- public Object peekNext() {
- return this.pos >= this.history.size() - 1 ? null : this.history.elementAt(this.pos + 1);
- }
- }
-